import { ApiProperty, PartialType } from '@nestjs/swagger';
import { CategoryDto, CurrencyDto, ExchangeRateDto, FeeCodDto, FeeCodModDto, FeedetDto, FeeEleDto, FeeEleLovDto, FeeModDto, FeeModEleDto, FeeTypDto, InvoiceDetailDto, InvoiceDto, PayDto, PrePayDto, ProtocolDto, ProtocolRatDto } from './create-business.dto';
import { IsString, IsNumber, IsNotEmpty, IsArray } from 'class-validator';
import { Type } from 'class-transformer';


export class UpdateProtocolDto extends PartialType(ProtocolDto) {
    @IsString(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'string',
    })
    primary_cod: string;
}

export class UpdateFeeEleDto extends PartialType(FeeEleDto) {
    @IsString(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'string',
    })
    primary_cod: string;
}


export class UpdateFeeEleLovDto extends PartialType(FeeEleLovDto) {
    @IsNotEmpty(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'object',
    })
    primary_cod: {fee_ele: string, fld_cod: string};
}

export class UpdateFeeTypCodDto {
    @IsString(
        {
            message: '缺少id',
        },
    )
    fee_typ: string;

    @IsArray() // 确保数组中的每个元素都是字符串
    @IsNotEmpty() // 确保数组不为空
    @Type(() => String) // 使用class-transformer确保类型安全
    feecods!: string[];
}
export class UpdateFeeModDto extends PartialType(FeeModDto) {
    @IsString(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'string',
    })
    primary_cod: string;
}

export class UpdateFeeModEleDto extends PartialType(FeeModEleDto) {
    @IsNotEmpty(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'object',
    })
    primary_cod: {fee_mod_cod: string, fee_ele: string};
}

export class UpdateFeeCodDto extends PartialType(FeeCodDto) {
    @IsString(
        {
            message: '缺少id',
        },
    )
    primary_cod: string;
}

export class UpdateFeeTypDto extends PartialType(FeeTypDto) {
    @IsString(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'string',
    })
    primary_cod: string;
}


export class UpdateFeeCodModDto extends PartialType(FeeCodModDto) {
    @IsNotEmpty(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'string',
    })
    primary_cod: {fee_cod: string, fee_mod: string};
}

export class UpdateCategoryDto extends PartialType(CategoryDto) {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'int',
    })
    id: number;
}

export class UpdateCurrencyDto extends PartialType(CurrencyDto) {
    @IsString(
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'string',
    })
    primary_cod: string;
}
export class UpdateExchangeRateDto extends PartialType(ExchangeRateDto) {
    @IsNotEmpty(
        {
            message: '缺少id',
        },
    )
    primary_cod: {from_currency: string, to_currency: string};
}
export class UpdateFeedetDto extends PartialType(FeedetDto) {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'int',
    })
    id: number;
}

export class UpdatePayDto extends PartialType(PayDto) {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'int',
    })
    id: number;
}
export class UpdatePrePayDto extends PartialType(PrePayDto) {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    id: number;
}
export class UpdateProtocolRateDto extends PartialType(ProtocolRatDto) {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'int',
    })
    id: number;
}

export class UpdateInvoiceDto extends PartialType(InvoiceDto) {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    @ApiProperty({
        example: 0,
        type: 'int',
    })
    id: number;
}

export class UpdateInvoiceDetailDto extends PartialType(InvoiceDetailDto) {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    id: number;
}